# -*- coding: UTF-8 -*-

import os
import sys
import xeres
import editor

from ui import control
from ui.font import *
from ui.image import *

from xeres import *

class Shelf( XForm ):
	def __init__(self):
		super(Shelf,self).__init__()
		menu = ( 'File','Edit','View','Environment','Tools','Interface' )
		for i in xrange(len(menu)):
			label = control.ClickLabel( self, menu[i], rect(i*80,0,78,14) )

class Dialog( XForm ):
	def __init__(self):
		super(Dialog,self).__init__( Point(300,200) )
		self.btn1 = control.SimpleButton( self, 'OK', statebtn('button$.tiff') ,(40,125), on_click=self.on_ok )
		self.btn2 = control.SimpleButton( self, 'Cancel', statebtn('button$.tiff') ,(160,125), on_click=self.on_cancel )
	
	def on_ok(self):
		editor.CloseDialog(1)
	
	def on_cancel(self):
		editor.CloseDialog(0)


def onclick():
	res = editor.OpenDialog( Dialog() )
	print "dialog " , res
	
class Panel( XForm ):
	def __init__( self ):
		super(Panel,self).__init__()
		control.ClickLabel( self, 'Panel' , rect(2,2,100,20) )

		self.btn1 = control.SimpleButton( self, 'test', statebtn('button$.tiff') ,(20,25), on_click=onclick )	


def init():
	editor.shelf.AddChild( Shelf() )
	editor.panel.AddChild( Panel() )

